package com.dailyblue.javaee.service.impl;

import com.dailyblue.javaee.bean.Emp;
import com.dailyblue.javaee.dao.EmpDAO;
import com.dailyblue.javaee.service.EmpService;

import java.util.List;

public class EmpServiceImpl implements EmpService {

    private EmpDAO edao;

    public EmpServiceImpl() {
        this.edao = new EmpDAO();
    }

    @Override
    public List<Emp> find() {
        return edao.find();
    }

    @Override
    public List<Emp> find(int page) {
        return edao.find(page);
    }

    @Override
    public int findAllPageNum() {
        int count = edao.findAllCount();
        int pages = count % 10 == 0 ? (count / 10) : (count / 10 + 1);
        return pages;
    }
    @Override
    public void delete(int id) {
        edao.delete(id);
    }
    @Override
    public List<Emp> findByEnname(String enname, int page) {
        return edao.findByEnname(enname, page);
    }

    @Override
    public int findAllPageNum(String enname) {
        int count = edao.findAllCount(enname);
        int pages = count % 10 == 0 ? (count / 10) : (count / 10 + 1);
        return pages;
    }
}